<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCouponsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('coupons', function (Blueprint $table) {
            $table->id();
            $table->string('name')->nullable();
            $table->string('type')->nullable()->comment("卡卷类型 coupon为优惠卷，park为停车卷，admission为门票");
            $table->string('scope')->nullable()->comment("优惠卷的关联范围  globe为全场通用，shop为指定商户");
            $table->string('func')->nullable()->comment('类型:固定金额/百分比 fixed 为固定金额， percent为百分比');
            $table->unsignedInteger('total')->default(0)->comment('总发行量');
            $table->decimal('value', 10, 2)->comment('优惠金额(金额或百分比)');

            $table->decimal('min_amount', 10, 2)->default(0)->comment('最低消费金额');
            $table->dateTime('start_time')->comment('生效时间');
            $table->dateTime('end_time')->comment('过期时间');
            $table->boolean('enabled')->default(true)->comment('是否启用');
            $table->string('merchant_ids')->nullable()->comment('商户ID');
            $table->integer('hours')->default(0)->comment('减免时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('coupons');
    }
}
